|
let id x = x in (id True, id 1) id's type is (for all a: a -> a). The universal quantifier "for all a:" means that a is a generic type variable. For the two uses of id, a is instantiated to Bool and Int. Compare this with let id x = x in let f g = (g True, g 1) in f id This looks similar but f has no legal {Hindley-Milner type}. If we say f :: (a -> b) -> (b, b) this would permit g's type to be any instance of (a -> b) rather than requiring it to be at least as general as (a -> b). Furthermore, it constrains both instances of g to have the same result type whereas they do not. The type variables a and b in the above are implicitly quantified at the top level: f :: for all a: for all b: (a -> b) -> (b, b) so instantiating the スポンサード リンク
|